<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt"  prefix="fmt" %>

<!DOCTYPE html>
<html>
<head>
	<title>修改信息</title>

	<meta name="viewport" content="width=device-width, initial-scale=1.0">
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
	<!-- 引入bootstrap -->
	<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/bootstrap.min.css">
	<!-- 引入JQuery  bootstrap.js-->
	<script src="<%=request.getContextPath()%>/js/jquery-3.2.1.min.js"></script>
	<script src="<%=request.getContextPath()%>/js/bootstrap.min.js"></script>
</head>
<body>
	<!-- 顶栏 -->
	<jsp:include page="top.jsp"></jsp:include>
	<!-- 中间主体 -->
	<div class="container" id="content">
		<div class="row">
			<jsp:include page="menu.jsp"></jsp:include>
			<div class="col-md-10">
				<div class="panel panel-default">
				    <div class="panel-heading">
						<div class="row">
					    	<h1 style="text-align: center;">修改个人信息</h1>
						</div>
				    </div>
				    <div class="panel-body">
						<form enctype="multipart/form-data" class="form-horizontal" role="form" action="${pageContext.request.contextPath}/student/doEditStudent" id="editfrom" method="post">
							<div class="form-group ">
								  <label for="inputEmail3" class="col-sm-2 control-label" >用户ID</label>
								  <div class="col-sm-10">
									  <input readonly="readonly" type="text" class="form-control" id="inputEmail3" name="userid" placeholder="请输入学号"
									  <c:if test='${student!=null}'> value="${student.userid}" </c:if> >
								  </div>
							</div>
							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label">用户名</label>
								<div class="col-sm-10">
									<input type="text" class="form-control" id="inputPassword3" name="username" placeholder="请输入姓名" value="${student.username}">
								</div>
							</div>
							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label">头像</label>
								<div class="col-sm-10">
									<input type="file" name="file">
									<img width="50px" height="50px" id="img" alt="头像" src="/image/${student.studentimg }">
								</div>
							</div>
<%--							<div class="form-group">--%>
<%--								<label for="password" class="col-sm-2 control-label">密码</label>--%>
<%--								<div class="col-sm-10">--%>
<%--									<input type="text" class="form-control" id="password" name="password" placeholder="请输入密码" value="${student.password}">--%>
<%--								</div>--%>
<%--							</div>--%>
							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label">性别</label>
								<div class="col-sm-10">
									<input type="text" id="sexText" value="${student.sex}" style="display: none">
									<label class="checkbox-inline">
										<input type="radio" name="sex" value="男" >男
									</label>
									<label class="checkbox-inline">
										<input type="radio" name="sex" value="女">女
									</label>
								</div>
							</div>
							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label">生日</label>
								<div class="col-sm-10">
									<input  type="date" value="<fmt:formatDate value="${student.birthyear}" dateStyle="medium" pattern="yyyy-MM-dd" />" name="birthyear"/>
								</div>
							</div>
							<div class="form-group">
								<label for="inputPassword3" class="col-sm-2 control-label" name="grade">注册时间</label>
								<div class="col-sm-10">
									<input readonly="readonly" type="date" value="<fmt:formatDate value="${student.grade}" dateStyle="medium" pattern="yyyy-MM-dd" />" name="grade"/>
								</div>
							</div>
							<div class="form-group">
								<label for="college" class="col-sm-2 control-label" name="grade">所属院系</label>
								<div class="col-sm-10">
									<select class="form-control" name="collegeid" id="college">
										<c:forEach items="${collegeList}" var="item">
											<option value="${item.collegeid}">${item.collegename}</option>
										</c:forEach>
									</select>
								</div>
							</div>
							<div class="form-group" style="text-align: center">
								<button class="btn btn-default" type="submit">提交</button>
								<button class="btn btn-default" type="reset">重置</button>
							</div>
						</form>
				    </div>
					<div class="panel-footer"> </div>
				</div>

			</div>
		</div>
	</div>
	<div class="container" id="footer">
		<div class="row">
			<div class="col-md-12"></div>
		</div>
	</div>
</body>
	<script type="text/javascript">
		//1
		$("#nav li:nth-child(3)").addClass("active")

		//2
        var collegeSelect = $("#college option");
        for (var i=0; i<collegeSelect.length; i++) {
            if (collegeSelect[i].value == '${student.collegeid}') {
                collegeSelect[i].selected = true;
            }
        }

        //3
		var val=document.getElementById("sexText").value;
		$(":radio[name='sex'][value='" + val + "']").prop("checked", "checked");
	</script>
</html>